package org.vic.strategy.demo03.improve.annotation;

import org.vic.strategy.demo03.CalPrice;

/**
 * Created by VIC.Huang on 2016/8/24.
 */
public class Customer {
    private Double totalAmount = 0D;        // 累计消费总额
    private Double amount = 0D;             // 本次消费金额
    private CalPrice calPrice = new DiffType4CalPrice().new Common();   // 默认初始计算价格策略

    // 客户购买单品，增加总额以便最后决定采取何种价格计算策略
    public void buy(Double amount) {
        this.amount = amount;
        totalAmount += amount;
        calPrice = CalPriceFactoryHandler.getInstance().createCalPrice(this);
    }

    // 计算客户最终支付价格
    public Double calPayAmount() {
        return calPrice.calPrice(amount);
    }

    public Double getTotalAmount() {
        return totalAmount;
    }

    public Double getAmount() {
        return amount;
    }
}
